package com.xxzuibang.day6.testti;

//10.去除数组{1,3,1,4,2,3,6,1,5}中的重复项,存入一个新的数组,并从大到小排序.
public class Test10 {
    public static void main(String[] args) {
        int[] arr={1,3,1,4,2,3,6,1,5};
        int number=0;
        int count=0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 1; j < arr.length-i; j++) {
                int temp=0;
                if(arr[j]>arr[j-1]){
                    temp=arr[j];
                    arr[j]=arr[j-1];
                    arr[j-1]=temp;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            number=arr[i];
            boolean s=true;
            for (int j = 0; j < i; j++) {
                if(number==arr[j]){
                    count++;
                    s=false;
                }
            }
            if(!s){
                arr[i]=-1;
            }else{
                arr[i]=number;
            }
        }
        int b[]=new int[arr.length-count];
        int j=0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]!=-1){
                b[j]=arr[i];
                j++;
            }
        }
        for (int i = 0; i < b.length; i++) {
            System.out.print(b[i]+" ");
        }

    }
}
